//app.js
App({
	//全局数据
	globalData: {
    appStatusBarHeight: wx.getStorageSync('statusBarHeight') + 'px',
	  //用户信息
	  userInfo: null,
	  //登录状态
	  logged: false
	},

	onLaunch: function() {
		let that = this
		if (!wx.cloud) {
			console.error('请使用 2.2.3 或以上的基础库以使用云能力')
		} else {
			wx.cloud.init({
				env: 'timemechine-6gk33n8ja79a3c4a'
			})
		}
		wx.cloud.callFunction({
      name: "getOpenid",
      success(res) {
        wx.cloud.callFunction({
					name:"getLogin",
					data:{
						"openid":res.result.openid
					},
					success(res){
						if(res.result.data[0].isLoged){
							that.globalData.logged = true
						} else {
							that.globalData.logged = false
						}
					},
					fail(err){
						console.log(err);
						that.globalData.logged = false
					}
				})
      },
      fail(err) {
        console.log("获取用户openid失败", err);
      }
    })
		wx.getSystemInfo({
      success: e => {
        this.globalData.StatusBar = e.statusBarHeight;
        let capsule = wx.getMenuButtonBoundingClientRect();
		if (capsule) {
		 	this.globalData.Custom = capsule;
			this.globalData.CustomBar = capsule.bottom + capsule.top - e.statusBarHeight;
		} else {
			this.globalData.CustomBar = e.statusBarHeight + 50;
		}
      }
    })
	},
	
})